package com.stageadminserver.adminserver.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.stageadminserver.adminserver.service.OrderCommentService;
import com.stagecommon.common.pojo.OrderComment;
import com.stagecommon.common.pojo.RespBean;
import com.stagecommon.common.vo.OrderCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单评论控制
 * @author: yxl
 * @since: 2022-01-14
 **/
@RestController
@RequestMapping("/orderComment")
public class OrderCommentController {

    @Autowired
    private OrderCommentService orderCommentService;

    /**
     * 分页获取订单评论
     * @param currentPage
     * @param size
     * @param orderComment
     * @return
     */
    @PostMapping("/getAllOrderCommentsByPage")
    public RespBean<IPage<OrderComment>> getAllOrderCommentsByPage(@RequestParam(defaultValue = "1") Integer currentPage,
                                                                   @RequestParam(defaultValue = "10") Integer size,
                                                                   @RequestBody OrderComment orderComment){
        return orderCommentService.selectAllOrderCommentsByPage(currentPage,size,orderComment);
    }

    /**
     * 根据订单评论id修改订单评论
     * @param orderComment
     * @return
     */
    @PostMapping("/changeOrderCommentById")
    public RespBean<Integer> changeOrderCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.changeOrderCommentById(orderComment);
    }

    /**
     * 添加订单评论
     * @param orderComment
     * @return
     */
    @PostMapping("/adminAddOrderComment")
    public RespBean<Integer> adminAddOrderComment(@RequestBody OrderComment orderComment){
        return orderCommentService.adminAddOrderComment(orderComment);
    }

    /**
     * 根据评论id查询订单评论信息
     * @param orderComment
     * @return
     */
    @PostMapping("/selectCommentById")
    public RespBean<OrderCommentVo> selectCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.selectCommentById(orderComment);
    }

    /**
     * 根据订单评论id删除评论
     * @param orderComment
     * @return
     */
    @PostMapping("/deleteOrderCommentById")
    public RespBean<Integer> deleteOrderCommentById(@RequestBody OrderComment orderComment){
        return orderCommentService.deleteOrderCommentById(orderComment);
    }

}
